package com.ls.markt.service.superLeague.impl;

import com.ls.markt.model.superLeague.SuperLeague;
import com.ls.markt.repository.superLeague.SuperLeagueRepository;
import com.ls.markt.service.superLeague.SuperLeagueService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
@Service
public class SuperLeagueServiceImpl implements SuperLeagueService {

    @Resource
    private SuperLeagueRepository superLeagueRepository;


    @Override
    public Page<SuperLeague> listSuperLeagues(PageRequest pageRequest) {
        return superLeagueRepository.findAll(pageRequest);
    }

    @Override
    public void save(SuperLeague superLeague) {
        superLeagueRepository.save(superLeague);
    }

    @Override
    public SuperLeague getById(Long id) {
        return superLeagueRepository.getOne(id);
    }

    @Override
    public void removeSuperLeagues(Long[] ids) {
        for (Long id:ids){
            superLeagueRepository.deleteById(id);
        }
    }
}
